package com.hb.trade.server.center.au.manager;

import cn.hutool.core.collection.CollUtil;
import cn.hutool.extra.spring.SpringUtil;
import com.hb.core.pojo.center.au.dto.OrgCollectionDTO;
import com.hb.core.pojo.center.au.dto.OrgPayeeDTO;
import com.hb.core.pojo.center.au.entity.OrgCollection;
import com.hb.core.pojo.center.au.entity.OrgPayee;
import com.hb.core.pojo.center.au.mapper.OrgCollectionMapper;
import com.hb.trade.server.center.au.service.OrgCollectionService;

import java.util.List;

/**
 * describe:
 * 企业收款方式领域模型
 * @author zhongdl
 * @date 2022/02/14
 */
public class OrgPayeeManger extends OrgPayeeDTO {




    public void fillOrgPayee(){
        if (this.getId() == null){
            buildBaseData(1);
        }else {
            buildBaseData(2);
        }
        List<OrgCollectionDTO> orgCollectionList = this.getOrgCollectionList();
        if (CollUtil.isEmpty(orgCollectionList)){
            return;
        }
        for (OrgCollectionDTO orgCollectionDTO : orgCollectionList) {
            if (orgCollectionDTO.getId() == null){
                orgCollectionDTO.buildBaseData(1);
            }else {
                orgCollectionDTO.buildBaseData(2);
                orgCollectionDTO.setDeleteFlag(0);
            }
            orgCollectionDTO.setPayeeId(getId());
        }
    }


    /**
     *
     * @Description:校验收款方式有没有被管理
     **/
    public String verifyAssociation(){
        OrgCollectionService orgCollectionService = SpringUtil.getBean(OrgCollectionService.class);
        List<OrgCollectionDTO> orgCollectionDTOS = orgCollectionService.listOrgCollectionByPayeeId(getId());
        if (CollUtil.isEmpty(orgCollectionDTOS)){
            return null;
        }
        Long orgId = getOrgId();

        for (OrgCollectionDTO orgCollectionDTO : orgCollectionDTOS) {

        }
        return null;
    }



}
